package com.framework.web.bus.service;
import com.framework.web.bus.domain.CookingSteps;
import com.framework.web.bus.domain.Ingredients;
import com.framework.web.bus.repository.CookingStepsRepository;
import com.framework.web.bus.repository.specifications.CookingStepsSpecs;
import com.framework.web.common.domain.BusinessConstants;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageRequest;
import org.springframework.stereotype.Service;

import java.util.List;

/**
* @Title: Service
* @Description: 业务层
* @author zqtao
* @date 2016-09-08
* @version V1.0
*
*/
@Service
public class CookingStepsService {

@Autowired
private CookingStepsRepository cookingStepsRepository;

/**
* 新增或者保存
* @param planlibrary
* @return
*/
public CookingSteps save(CookingSteps planlibrary) {
    return cookingStepsRepository.save(planlibrary);
}

/**
* 删除(逻辑)
* @param id
*/
public void  delete(String id) {
    CookingSteps cookingSteps = cookingStepsRepository.findOne(id);
    cookingSteps.setStatus(BusinessConstants.STATUS.remove);
    cookingStepsRepository.save(cookingSteps);
}
/**
* 根据id查询
* @param id
* @return
*/
public CookingSteps findById(String id) {
    return cookingStepsRepository.findOne(id);
}


/**
* 分页查找
* @param CookingSteps
* @param pr
* @return
*/
public Page<CookingSteps> getPageList(CookingSteps CookingSteps, PageRequest pr) {
    Page<CookingSteps> totalList = cookingStepsRepository.findAll(CookingStepsSpecs.pageQueryPlanlibrary(CookingSteps), pr);
    return totalList;
}

/**
 * 根据菜谱ID获取不走列表
 * @param cookbookId
 * @return
 */
public List<CookingSteps> findByCookbookId(String cookbookId) {
    return cookingStepsRepository.findByCookbookId(cookbookId);
}

}
